<template>
  <div>
    <p class="enter-title">请输入手机号码</p>
    <mt-field style="width: 60%;margin: 10px auto;border: 1px solid #c1bfc5;font-size: 16px;border-radius: 2px;" label="" placeholder="请输入手机号" type="tel" v-model="phone" :attr="{ maxlength: 11 }"></mt-field>
    <p style="color:#3385ff;text-align: center;">手机号码是出场凭证，请您牢记!</p>
    <div class="okBtn" @click="onHandle">确定入场</div>
  </div>
</template>

<script>

import { noCarQRcodeInOutPark } from '@/api/parkEnter/parkEnter'

export default {
  name: 'parkEnter',
  data() {
    return {
      query: {},
      phone: ''
    }
  },
  created() {
    this.query = this.$utils.getQueryString(window.location)
    console.log(this.query)
  },
  methods: {
    onHandle: function () {
      // noCarQRcodeInOutPark
      if (!/^1[34578]\d{9}$/.test(this.phone)) {
        this.$msgbox('提示', '请输入正确手机号')
        return
      }
      if (this.query == null) {
        this.$msgbox('提示', '没有接收到请求参数')
        return
      }

      this.query.app_id = 1
      this.query.salt = 2
      this.query.deviceInfo = 3
      this.query.sign_type = 'md5'
      this.query.sign = 4
      this.query.token = '666'

      this.query.carNumber = this.phone+'111'
      this.query.terminalSource = "7";//增加字段：1:任你听 3：微信公共号 4:云平台 7:H5
      noCarQRcodeInOutPark(this.query).then(res => {
        if (res.code == 0) {
          this.$msgbox('提示', '进场信息已录入,请您进场！')
        } else {
          this.$msgbox('提示', res.message)
        }
      })

    }
  }
}
</script>

<style scoped lang="scss">
  .enter-title {
    margin-top: 45px;
    text-align: center;
    font-size: 18px;
    color: #000;
  }
  .okBtn{
    background: linear-gradient(180deg, #3885D9 0%, #4194EF 100%);
    width: 60%;
    margin: 50px auto 0;
    height: 48px;
    line-height: 48px;
    text-align: center;
    border-radius: 5px;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
  }
</style>
